package kr.hkit.powerjava.chapter11;

class Book {
	String title;
	String writer;
	int page;
	
	public Book() {}

	public Book(String title, String writer, int page) {
		this.title = title;
		this.writer = writer;
		this.page = page;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWriter() {
		return writer;
	}

	public void setWriter(String writer) {
		this.writer = writer;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	@Override
	public String toString() {
		return String.format("Book [title=%s, writer=%s, page=%s]", title,
				writer, page);
	}

}

class Magazine extends Book {
	String onSale;

	public Magazine(String title, String writer, int page, String onSale) {
		super(title, writer, page);
		this.onSale = onSale;
	}

	public String getOnSale() {
		return onSale;
	}

	public void setOnSale(String onSale) {
		this.onSale = onSale;
	}

	@Override
	public String toString() {
		return String.format(
				"Magazine [onSale=%s, title=%s, writer=%s, page=%s]", onSale,
				title, writer, page);
	}
}

public class BookTest{
	public static void main(String[] args) {
		Book sleep = new Book();
		sleep.setPage(258);
		sleep.setTitle("잠을 잡시다");
		sleep.setWriter("김불면");
		
		Magazine fun = new Magazine(sleep.title, sleep.writer, sleep.page, "2015.1.30");
		System.out.println(sleep);
		System.out.println(fun);
	}
}
